test: Convert testinput to Cairo
authorBenjamin Otte <otte@redhat.com>
Thu, 15 Jul 2010 16:37:08 +0000 (18:37 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Jul 2010 14:42:48 +0000 (16:42 +0200)
The test is broken though as it draws onto windows outside of expose
events.
And we all know you shouldn't do that.

tests/testinput.c

index 5a81b8eb26daa4c2d47512efd5e271caef57ad2e..16ad3ee7e66d0b398201715c75a8092b0020928b 100644 (file)
@@ -52,16 +52,14 @@ update_cursor (GtkWidget *widget,  gdouble x, gdouble y)
 
   if (pixmap != NULL)
     {
+      cairo_t *cr = gdk_cairo_create (widget->window);
+
       if (cursor_present && (cursor_present != state ||
                             x != cursor_x || y != cursor_y))
        {
-          cairo_t *cr = gdk_cairo_create (widget->window);
-
           gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
           cairo_rectangle (cr, cursor_x - 5, cursor_y - 5, 10, 10);
           cairo_fill (cr);
-
-          cairo_destroy (cr);
        }
 
       cursor_present = state;
@@ -70,12 +68,14 @@ update_cursor (GtkWidget *widget,  gdouble x, gdouble y)
 
       if (cursor_present)
        {
-         gdk_draw_rectangle (widget->window,
-                             widget->style->black_gc,
-                             TRUE,
-                             cursor_x - 5, cursor_y -5,
-                             10, 10);
+          cairo_set_source_rgb (cr, 0, 0, 0);
+          cairo_rectangle (cr, 
+                           cursor_x - 5, cursor_y -5,
+                          10, 10);
+          cairo_fill (cr);
        }
+
+      cairo_destroy (cr);
     }
 }
 
@@ -122,31 +122,36 @@ static void
 draw_brush (GtkWidget *widget, GdkInputSource source,
            gdouble x, gdouble y, gdouble pressure)
 {
-  GdkGC *gc;
+  GdkColor color;
   GdkRectangle update_rect;
+  cairo_t *cr;
 
   switch (source)
     {
     case GDK_SOURCE_MOUSE:
-      gc = widget->style->dark_gc[gtk_widget_get_state (widget)];
+      color = widget->style->dark[gtk_widget_get_state (widget)];
       break;
     case GDK_SOURCE_PEN:
-      gc = widget->style->black_gc;
+      color.red = color.green = color.blue = 0;
       break;
     case GDK_SOURCE_ERASER:
-      gc = widget->style->white_gc;
+      color.red = color.green = color.blue = 65535;
       break;
     default:
-      gc = widget->style->light_gc[gtk_widget_get_state (widget)];
+      color = widget->style->light[gtk_widget_get_state (widget)];
     }
 
   update_rect.x = x - 10 * pressure;
   update_rect.y = y - 10 * pressure;
   update_rect.width = 20 * pressure;
   update_rect.height = 20 * pressure;
-  gdk_draw_rectangle (pixmap, gc, TRUE,
-                     update_rect.x, update_rect.y,
-                     update_rect.width, update_rect.height);
+
+  cr = gdk_cairo_create (pixmap);
+  gdk_cairo_set_source_color (cr, &color);
+  gdk_cairo_rectangle (cr, &update_rect);
+  cairo_fill (cr);
+  cairo_destroy (cr);
+
   gtk_widget_queue_draw_area (widget,
                              update_rect.x, update_rect.y,
                              update_rect.width, update_rect.height);